<?php


namespace app\admin\controller;

use think\Controller;
use think\Db;

class Yuyue extends Base
{
//财务报表
    public function index()
    {

        if (request()->isAjax()) {
            $page = input('page') ? input('page') : 1;
            $limit = input('limit') ? input('limit') : 10;
            $gd = Db::name('yuyue');

            $res = $gd->page($page, $limit)->select();
            foreach ($res as $index => $re) {
                $res[$index]['create_time'] = date('Y-m-d H:i:s', $re['create_time']);
            }
            $this->success('ok', '', $res);

        } else {
            $count = Db::name('yuyue')->count();
            $this->assign('count', $count);
            return $this->fetch();
        }

        // for ($i=0;$i<7;$i++){
        //     foreach ($res as $index => $re) {
        //         $data=$re;
        //         unset($data['id']);
        //         // var_dump($data);
        //         $gd->insertGetId($data);
        //     }
        // }

    }


//删除操作
    public function del(){
        $data = input('');
        $ids = $data['ids'];
        foreach ($ids as $id) {
            $res = Db::name('yuyue')->where('id', $id)->delete();
        }
        if ($res) {
            $this->success('操作成功');
        }
    }


    //未受理  已受理  按钮编辑
    public function wsl()
    {
        if (request()->isAjax()) {

            $data = input('data_id');
            //   $id=$data['id'];
            $res = Db::name('yuyue')

                ->where('id',$data)->update(["status"=>0]);
            if ($res === false) {
                $this->success('操作失败');
            }
            $this->success('操作成功');
        }
    }
    public function sl()
    {
        if (request()->isAjax()) {

            $data = input('data_id');
            //   $id=$data['id'];
            $res = Db::name('yuyue')

                ->where('id',$data)->update(["status"=>1]);
            if ($res === false) {
                $this->success('操作失败');
            }
            $this->success('操作成功');
        }
    }



}
